home *** CD-ROM | disk | FTP | other *** search
- 100 ' SOLID STATES FROM ANALOG ISSUE #16
- 110 ' CONVERTED TO ST BASIC BY JIM LUCZAK
- 120 ' For complete instructions see ANALOG issues # 16,19 and 22
- 130 ' To enter your own parameters use option K
- 140 ' To enter a data file with pre-entered parameters use option F
- 150 ' Good settings for SHIP.DAT
- 160 ' OBSERVER LOC. LOOKED AT ZOOM
- 170 ' 60,-60,40 0,0,0 1
- 180 ' 0,-45,6 0,0,0 1
- 190 ' 1,0,150 0,0,0 2
- 200 ' Good settings for TIEFIGHT.DAT
- 210 ' 100,173,50 0,0,0 4
- 220 ' 100,200,100 0,0,0 4
- 230 ' 100,200,100 0,10,0 4
- 232 ' Good settings for XWING.DAT
- 234 ' 0,0,100 30,25,5 .5
- 236 ' 0,20,50 30,25,10 .5
- 238 ' 50,80,30 20,40,10 .5
- 240 ' ---------------------- SEE WHAT REZ WE ARE -----------------------------
- 250 if peek(systab)=4 then xr=319:yb=199:tx=5:ty=2:tc=4:md=20 ' LOW
- 260 if peek(systab)=2 then xr=639:yb=199:tx=23:ty=2:tc=2:md=35 ' MEDIUM
- 270 if peek(systab)=1 then xr=639:yb=399:tx=40:ty=4:tc=1:md=35 ' HIGH
- 280 ' ------------------ CLEAR SCREEN WRITE TITLE PAGE -----------------------
- 290 fullw 2:clearw 2
- 300 ' -------------------------SET FILL COLOR INDEX --------------------------
- 310 poke contrl,25
- 320 poke contrl+2,0
- 330 poke contrl+6,1
- 340 poke intin,tc ' COLOR INDEX 0-15 LOW 0-3 MED 0-1 HIGH
- 350 vdisys(1)
- 360 ' ------------------------ SET FILL INTERIOR STYLE -----------------------
- 370 poke contrl,23
- 380 poke contrl+2,0
- 390 poke contrl+6,1
- 400 poke intin,2 ' 0=HOLLOW 1=SOLID 2=PATTERN 3=HATCH 4=USER DEFINED
- 410 vdisys(1)
- 420 ' ------------------------ SET FILL STYLE INDEX --------------------------
- 430 poke contrl,24
- 440 poke contrl+2,0
- 450 poke contrl+6,1
- 460 poke intin,4 ' 1-24 FOR PATTERN 1-12 FOR HATCH
- 470 vdisys(1)
- 480 ' -------------------- DRAW ROUNDED FILLED RECTANGLE ---------------------
- 490 poke contrl,11
- 500 poke contrl+2,3
- 510 poke contrl+6,0
- 520 poke contrl+10,9 ' PRIMITIVE ID 8=ROUNDED RECT. 9=FILLED ROUNDED RECT.
- 530 poke ptsin,xr-md ' X COORD OF LOWER RIGHT CORNER
- 540 poke ptsin+2,yb-15 ' Y COORD OF LOWER RIGHT CORNER
- 550 poke ptsin+4,5 ' X COORD OF UPPER LEFT CORNER
- 560 poke ptsin+6,25' Y COORD OF UPPER LEFT CORNER
- 570 vdisys(1)
- 580 ' ------------------------- SET WRITING MODE ----------------------------
- 590 poke contrl,32
- 600 poke contrl+2,0
- 610 poke contrl+6,1
- 620 poke intin,2 ' 1=REPLACE 2=TRANSPARENT 3=XOR 4=REVERSE TRANSPARENT
- 630 vdisys(1)
- 640 tse=9:gosub SETEFFECTS
- 650 gotoxy tx+4,ty:?"** SOLID STATES **"
- 660 tse=0:gosub SETEFFECTS
- 670 gotoxy tx,ty+4:?"A 3D OBJECT PLOTTING SYSTEM"
- 680 gotoxy tx,ty+6:?"ANALOG ISSUES 16, 19, and 22"
- 690 tse=4:gosub SETEFFECTS
- 700 gotoxy tx-5,ty+8:?"Converted to ST BASIC by JAMES LUCZAK"
- 710 tse=16:gosub SETEFFECTS
- 720 gotoxy tx,ty+10:?"READ REM'S FOR INSTRUCTIONS"
- 730 tse=0:gosub SETEFFECTS
- 740 gotoxy tx,16:?"PRESS ANY KEY TO CONTINUE":input a$:clearw 2
- 750 ' -------------------- INIT AND PROGRAM START ----------------------------
- 760 xl=0:yt=0
- 770 a$="F":gosub HILITE:?"ile or ";:a$="K"
- 780 gosub HILITE:?"eyboard input ";:input a$
- 790 if a$="f" or a$="F" then goto LODEFILE
- 800 if a$<>"k" and a$<>"K" then 780
- 810 ' --------------------- ENTER DATA FROM KEYBOARD -------------------------
- 820 ?:?"How many ";:a$="POINTS":gosub HILITE:?" are there ";:input ps
- 830 dim x(ps),y(ps),z(ps),p(ps,2),vis(ps)
- 840 ?"Enter ";:a$="X,Y,Z":gosub HILITE:?" coordinates for each point"
- 850 for i=1 to ps:? "Point ";i;" ";:input x(i),y(i),z(i):next i
- 860 ?"How many ";:a$="LINES":gosub HILITE:?" are there ";:input ls:dim ln(ls,1)
- 870 ?"Now enter ";:a$="POINT":gosub HILITE:?" information for each line"
- 880 for i=1 to ls:?"LINE ";i:a$="FROM POINT ":gosub HILITE:input ln(i,0)
- 890 a$=" TO POINT ":gosub HILITE:input ln(i,1):next i
- 900 a$="Y/N ":?"Do you want to save this object ";:gosub HILITE:input a$
- 910 if a$="y" or a$="A" then goto SAVEFILE
- 920 if a$<>"n" and a$<>"N" then 900
- 930 ' --------------------- TIME FOR NEW PLOT ------------------------------
- 940 a$="E":gosub HILITE:?"dit ";:a$="Q":gosub HILITE:?"uit ";
- 950 a$="C":gosub HILITE:?"ontinue ";:input a$
- 960 if a$="e" or a$="E" then 1700
- 970 if a$="q" or a$="Q" then end
- 980 ' ---------------------- ENTER VIEWING PARAMETERS ------------------------
- 990 ?:?"Enter observer location ";:a$="X,Y,Z ":gosub HILITE
- 1000 zoom=1
- 1010 input ox,oy,oz
- 1020 ?:?"Enter coordinates looked at ";:a$="X,Y,Z ":gosub HILITE
- 1030 input vx,vy,vz
- 1040 ?:?"Enter ";:a$="ZOOM ":gosub HILITE:?"factor "
- 1050 input zoom
- 1060 d0=1:x(0)=vx:y(0)=vy:z(0)=vz
- 1070 ' ----------------------CALCULATE PERSPECTIVE --------------------------
- 1080 dx=vx-ox:dy=vy-oy:dz=vz-oz
- 1090 u1=sqr(dx*dx+dy*dy+dz*dz):if u1=0 then u1=.000001
- 1100 cx=dx/u1:cy=dy/u1:cz=dz/u1
- 1110 s3=sqr(1-cz*cz):s2=sqr(1-cy*cy)
- 1120 qx=ox+d0*cx:qy=oy+d0*cy:qz=oz+d0*cz
- 1130 for i=0 to ps:xw=x(i):yw=y(i):zw=z(i):gosub POINTVIS:next i
- 1140 for i=0 to ps:if vis(i)=0 then 1160
- 1150 xw=x(i):yw=y(i):zw=z(i):gosub POINTVIS:gosub CALCOORD
- 1160 next i:goto SCALEIMAGE
- 1170 ' -------------------- IS THE POINT VISIBLE ----------------------------
- 1180 POINTVIS: vis(i)=1:vcx=xw-ox:vcy=yw-oy:vcz=zw-oz
- 1190 if dx*vcx+dy*vcy+dz*vcz>0 then return
- 1200 vis(i)=0:return
- 1210 ' ---------------- NOW CALCULATE PLOT COORDINATES -----------------------
- 1220 CALCOORD: k=d0/(vcx*cx+vcy*cy+vcz*cz)
- 1230 ax=ox+k*vcx:ay=oy+k*vcy:az=oz+k*vcz
- 1240 if s3=0 then 1270
- 1250 p(i,1)=((ax-qx)*cy-(ay-qy)*cx)/s3
- 1260 p(i,2)=(az-qz)/s3:return
- 1270 p(i,1)=((qx-ax)*cz+(az-qz)*cx)/s2
- 1280 p(i,2)=(ay-qy)/s2:return
- 1290 ' ------------------------ SCALE THE IMAGE -----------------------------
- 1300 SCALEIMAGE: t=450*zoom:for i=0 to ps
- 1310 p(i,1)=p(i,1)*t
- 1320 p(i,2)=p(i,2)*t
- 1330 next i
- 1340 xad=(xr/2) -p(0,1):yad=(yb/2)-p(0,2):for i=1 to ps:p(i,1)=p(i,1)+xad
- 1350 p(i,2)=p(i,2)+yad:next i
- 1360 ' -------------------- NOW DRAW THE IMAGE -----------------------------
- 1370 clearw 2:color 1,0,1
- 1380 for i=1 to ls:tv=vis(ln(i,0))+vis(ln(i,1)):if tv=0 then 1510
- 1390 if tv=2 then 1490
- 1400 qt=0:isave=i:if vis(ln(i,0))=0 then i1=ln(i,0):i2=ln(i,1):i=ln(i,0):goto 1420
- 1410 i1=ln(i,1):i2=ln(i,0):i=ln(i,1)
- 1420 xt1=x(i1):yt1=y(i1):zt1=z(i1):xt2=x(i2):yt2=y(i2):zt2=z(i2):fv=0:fh=0
- 1430 xw=(xt1+xt2)/2:yw=(yt1+yt2)/2:zw=(zt1+zt2)/2:gosub POINTVIS
- 1440 if vis(i)>0 then xt2=xw:yt2=yw:zt2=zw:goto 1460
- 1450 xt1=xw:yt1=yw:zt1=zw
- 1460 qt=qt+1:if qt<15 then 1430
- 1470 xw=xt2:yw=yt2:zw=zt2:gosub POINTVIS
- 1480 gosub CALCOORD:p(i,1)=p(i,1)*t+xad:p(i,2)=p(i,2)*t+yad:vis(i)=0:i=isave
- 1490 x1=p(ln(i,0),1):y1=yb-p(ln(i,0),2):x2=p(ln(i,1),1):y2=yb-p(ln(i,1),2)
- 1500 gosub GRCLIP
- 1510 next i
- 1520 for x=15 to 0 step -1:sound 1,x,12,7,1:next x
- 1530 color 2,0,1:input"PRESS any key to continue ",a$:color 1,0,1
- 1540 clearw 2:?"Last parameters:"
- 1550 ?:?"OBSERVER: ";ox;",";oy;",";oz:?"VIEWPOINT: ";vx;",";vy;",";vz:?"ZOOM: "; zoom:goto 930
- 1560 ' ----------------------- LOAD 3-D IMAGE FILE ---------------------------
- 1570 LODEFILE: close 1:?"Enter ";:a$="FILENAME":gosub HILITE:?" to load ";
- 1580 input f$:open "I",1,f$
- 1590 input#1,ps:dim x(ps),y(ps),z(ps),p(ps,2),vis(ps)
- 1600 for x=1 to ps:input#1,x(x),y(x),z(x):next x
- 1610 input#1,ls:dim ln(ls,1)
- 1620 for x=1 to ls:input#1,ln(x,0),ln(x,1):next x
- 1630 close 1: goto 930
- 1640 ' ----------------------- SAVE 3-D IMAGE FILE ----------------------------
- 1650 SAVEFILE: close 1:?"Enter ";:a$="FILENAME":gosub HILITE:?" to save ";
- 1660 input f$:open "O",1,f$
- 1670 write #1,ps
- 1680 for x=1 to ps:write #1,x(x),y(x),z(x):next x
- 1690 write #1,ls:for x=1 to ls:write #1,ln(x,0),ln(x,1):next x:goto 1630
- 1700 ' ---------------------- EDIT 3-D IMAGE FILE ----------------------------
- 1710 ?:a$="E":gosub HILITE:?"dit ";:a$="P":gosub HILITE:?"rint or ";:a$="Q"
- 1720 gosub HILITE:?"uit ";:input a$
- 1730 if a$="e" or a$="E" then 1800
- 1740 if a$="q" or a$="Q" then 930
- 1750 if a$<>"p" and a$<>"P" then 1700
- 1760 lprint"POINTS:";ps:lprint
- 1770 for x=1 to ps:lprint"POINT ";x;": ";x(x),y(x),z(x):next x:lprint
- 1780 lprint"LINES:";ls:lprint
- 1790 for x=1 to ls:lprint"LINE ";x;": ";ln(x,0);" To ";ln(x,1):next x:lprint:goto 1700
- 1800 ?:?"Edit ";:a$="P":gosub HILITE:?"oint or ";:a$="L":gosub HILITE:?"ine or ";
- 1810 a$="Q":gosub HILITE:?"uit ";:input a$:if a$="l" or a$="L" then 1900
- 1820 if a$="q" or a$="Q" then 900
- 1830 if a$<>"p" and a$<>"P" then 1800
- 1840 ?:a$="POINT":gosub HILITE:?"# or ";:a$="RETURN ":gosub HILITE
- 1850 input pt$:if pt$="" then 1800
- 1860 pt=val(pt$):if pt>ps or pt <0 then 1840
- 1870 ?:?"x=";x(pt),"y=";y(pt),"z=";z(pt)
- 1880 ?:?"Enter new ";:a$="X Y Z ":gosub HILITE
- 1890 input x(pt),y(pt),z(pt):goto 1800
- 1900 ?:?"Enter ";:a$="LINE":gosub HILITE:?"# or ";:a$="RETURN":gosub HILITE
- 1910 input ln$:if ln$="" then 1800
- 1920 ln=val(ln$):if ln>ls or ln<0 then 1900
- 1930 ?:?"From POINT:";ln(ln,0);:?" To POINT:";ln(ln,1)
- 1940 ?:?"Enter new LINE POINTS "
- 1950 a$="From POINT ":gosub HILITE:input q1:if q1>ps then 1950
- 1960 ln(ln,0)=q1
- 1970 a$=" To POINT ":gosub HILITE:input q1:if q1>ps then 1970
- 1980 ln(ln,1)=q1:goto 1800
- 1990 ' ------------------- GRAPHICS CLIP ROUTINE -----------------------------
- 2000 GRCLIP:
- 2010 l1=0:l2=0:r1=0:r2=0:t1=0:t2=0:b1=0:b2=0
- 2020 if x1<xl then l1=1:goto 2040
- 2030 if x1>xr then r1=1
- 2040 if y1>yb then b1=1:goto 2060
- 2050 if y1<yt then t1=1
- 2060 if x2<xl then l2=1:goto 2080
- 2070 if x2>xr then r2=1
- 2080 if y2>yb then b2=1:goto 2100
- 2090 if y2<yt then t2=1
- 2100 if l1+l2=2 or r1+r2=2 or t1+t2=2 or b1+b2=2 then return
- 2110 x3=x1:y3=y1:x4=x2:y4=y2:gosub 2160
- 2120 l1=l2:r1=r2:t1=t2:b1=b2
- 2130 x1=xw:y1=yw:x3=x2:y3=y2:x4=x1:y4=y1:gosub 2160
- 2140 if x1<xl or x1>xr or y1<yt or y1>yb or xw<xl or xw>xr or yw<yt or yw>yb then return
- 2150 linef x1,y1,xw,yw:return
- 2160 if l1+t1+b1+r1=0 then xw=x3:yw=y3:return
- 2170 if l1 then xw=xl:yw=y3+(y4-y3)*(xl-x3)/(x4-x3):x3=xw:y3=yw
- 2180 if y3>=yt and y3<=yb then return
- 2190 if r1 then xw=xr:yw=y3+(y4-y3)*(xr-x3)/(x4-x3):x3=xw:y3=yw
- 2200 if y3>=yt and y3<=yb then return
- 2210 if b1 then yw=yb:xw=x3+(x4-x3)*(yb-y3)/(y4-y3):x3=xw:y3=yw
- 2220 if x3>=xr and x3<=xl then return
- 2230 if t1 then yw=yt:xw=x3=(x4-x3)*(yt-y3)/(y4-y3):x3=xw:y3=yw
- 2240 return
- 2250 HILITE:
- 2260 color 2,0,1:?a$;:color 1,0,0:a$="":return
- 2270 ' -------------------- SET TEXT SPECIAL EFFECTS -------------------------
- 2280 SETEFFECTS:
- 2290 poke contrl,106
- 2300 poke contrl+2,0
- 2310 poke contrl+6,1
- 2320 poke intin,tse ' SETS SPECIAL EFFECT
- 2330 vdisys(1)
- 2340 return
- 2350 ' Special effects attributes are contained in a SIX BIT WORD.
- 2360 ' BIT 0 = THICKENED ( binary value=1 )
- 2370 ' BIT 1 = INTENSITY ( binary value=2 )
- 2380 ' BIT 2 = SKEWED ( binary value=4 )
- 2390 ' BIT 3 = UNDERLINED ( binary value=8 )
- 2400 ' BIT 4 = OUTLINED ( binary value=16 )
- 2410 ' BIT 5 = SHADOWED ( binary value = 32 )
- 2420 ' To have THICKENED text poke intin in line 2320 to 1
- 2430 ' To have UNDERLINED text poke intin to 8
- 2440 ' To have UNDERLINED LIGHT INTENSITY text poke intin to 10
- 2450 ' You can set any combination of special effects.
- 2460 ' Setting the bit activates the special effect.
- 2470 ' Resetting the bit deactivates the special effect.
- ə4444444444444444444444444444444444444444444444444444444444444444444444444444